﻿// See https://aka.ms/new-console-template for more information
using FreeDream.ConsoleApp;
using System.Xml.Linq;

Console.WriteLine("Hello, World!");
//test2();
DemoTest01 demoTest01 = new DemoTest01();
//demoTest01.beibao01();
demoTest01.BeibaoTest03();

Console.ReadLine();

static void test(int num)
{
    #region 生成随机不重复数据

    int[] intArray = new int[num];
    List<int> newArray = new List<int>();
    Random rnd = new Random();
    while (newArray.Count < num)
    {
        int tempNumber = rnd.Next(1, num + 1);
        if (!newArray.Contains(tempNumber))
            newArray.Add(tempNumber);
    }

    #endregion

    newArray.Sort();
    int mid = newArray.Count / 2;

    List<int> list = new List<int>();
    for (int i = 0; i < newArray.Count; i++)
    {
        if (i == mid)
        {
            if (newArray.Count % 2 == 1)
            {
                list.Add(newArray[i]);
            }
            break;
        }
        list.Add(newArray[i]);
        list.Add(newArray[newArray.Count - 1 - i]);
    }

    foreach (int i in list)
    {
        Console.WriteLine(i);
    }
    
}

static void test2()
{
    List<student> lst3 = new List<student>() 
    {
        new student{ id = 1,name = "01"}, new student{ id = 2,name = "02"}
    };

    var lst = new { id = 1, name = "01" };
    
    var a1 = int.Parse(lst.GetType().GetProperty("id").GetValue(lst, null).ToString());

    var tu1 = new Tuple<int, string>(int.Parse(lst.GetType().GetProperty("id").GetValue(lst,null).ToString()),
        lst.GetType().GetProperty("name").GetValue(lst, null).ToString()).Item1;
    var tu2 = new Tuple<int, string>(int.Parse(lst.GetType().GetProperty("id").GetValue(lst,null).ToString()),
        lst.GetType().GetProperty("name").GetValue(lst3, null).ToString()).Item2;
    var a2 = int.Parse(lst3.GetType().GetProperty("id").GetValue(lst3[0], null).ToString());//Object reference not set to an instance of an object:对象引用未设置为对象的实例

}
public class student
{
    public int id { get; set; }

    public string name { get; set; }
}